#include <vector>

using namespace std;

class Solution {
private:
    inline vector<double> check(double x, double y, vector<vector<vector<int>>>& range) {
        if (x >= range[0][0][0] && x <= range[0][0][1] && x >= range[1][0][0] && x <= range[1][0][1] && y >= range[0][1][0] && y <= range[0][1][1] && y >= range[1][1][0] && y <= range[1][1][1]) {
            return {x, y};
        }
        return {};
    }
public:
    vector<double> intersection(vector<int>& start1, vector<int>& end1, vector<int>& start2, vector<int>& end2) {
        vector<vector<vector<int>>> range = {{{min(start1[0], end1[0]), max(start1[0], end1[0])}, {min(start1[1], end1[1]), max(start1[1], end1[1])}}, {{min(start2[0], end2[0]), max(start2[0], end2[0])}, {min(start2[1], end2[1]), max(start2[1], end2[1])}}};
        if (end1[0] == start1[0] || end2[0] == start2[0]) {
            if (end1[0] == start1[0] && end2[0] == start2[0]) {
                if (end1[0] != end2[0] || range[0][1][0] > range[1][1][1] || range[1][1][0] > range[0][1][1]) {
                    return {};
                }
                return {(double) start1[0], (double) max(range[0][1][0], range[1][1][0])};
            } else if (end1[0] == start1[0]) {
                double k2 = (double) (end2[1] - start2[1]) / (end2[0] - start2[0]);
                double b2 = start2[1] - k2 * start2[0];
                return check(start1[0], k2 * start1[0] + b2, range);
            } else {
                double k1 = (double) (end1[1] - start1[1]) / (end1[0] - start1[0]);
                double b1 = start1[1] - k1 * start1[0];
                return check(start2[0], k1 * start2[0] + b1, range);
            }
        }
        vector<double> k = {(double) (end1[1] - start1[1]) / (end1[0] - start1[0]), (double) (end2[1] - start2[1]) / (end2[0] - start2[0])};
        vector<double> b = {start1[1] - k[0] * start1[0], start2[1] - k[1] * start2[0]};
        if (k[0] == k[1]) {
            if (b[0] != b[1] || range[0][0][0] > range[1][0][1] || range[1][0][0] > range[0][0][1]) {
                return {};
            }
            double x = max(range[0][0][0], range[1][0][0]);
            return {x, x * k[0] + b[0]};
        }
        double x = (b[1] - b[0]) / (k[0] - k[1]);
        double y = k[0] * x + b[0];
        return check(x, y, range);
    }
};